import { Dayjs } from 'dayjs'
import { TimeTool } from '../tool/TimeTool'
import { DateInfo } from './DateInfo'
import { WeekLocation } from './WeekLocation'

/**
 * 周信息
 */
export class WeekInfo {
    /**
     * 定位这一周的位置, 参考 {@link start} 计算
     */
    public readonly location: WeekLocation
    /**
     * 开始和结束时间
     */
    public readonly start: DateInfo
    public readonly end: DateInfo

    constructor(start: Dayjs, end: Dayjs) {
        this.start = new DateInfo(start)
        this.end = new DateInfo(end)
        this.location = TimeTool.weekLocation(start)
    }

    public equal(o: any): boolean {
        if (!o) {
            return false
        }
        return this.location.equal(o.location)
            && this.start.equal(o.start)
            && this.end.equal(o.end)
    }
}
